import http from '@/utils/http'
import type * as System from './type'

export function getAllRole() {
  return http.get<System.RoleItem[]>('/system/admin/role/list')
}

/** @desc 获取角色数据 */
export function getSystemRoleList(params: { pageNo: number; pageSize: number }) {
  return http.post<PageRes<System.RoleItem[]>>('/system/admin/role/page', params)
}

/** @desc 获取角色详情 */
export function getSystemRoleDetail(id: string) {
  return http.get<System.RoleItem>(`/system/admin/role/detail/${id}`)
}

/** @desc 保存角色 */
export function createSystemRole(data: any) {
  return http.post<boolean>('/system/admin/role/create', data)
}

export function modifySystemRole(data: any) {
  return http.post<boolean>('/system/admin/role/modify', data)
}

/** @desc 删除角色 */
export function deleteSystemRole(id: string) {
  return http.deleted<string[]>(`/system/admin/role/delete/${id}`)
}

/** @desc 获取角色权限 */
export function getSystemRoleMenuIds(id: string) {
  return http.get<string[]>(`/system/admin/role/menuIds/${id}`)
}
